#ifndef __GAME_GEOM_H__
#define __GAME_GEOM_H__


#include "game_def.h"


class CGamePoint {
public:
  INT32 x;
  INT32 y;

public:
  CGamePoint() :x{ 0 }, y{ 0 }{};
  CGamePoint(INT32 xx, INT32 yy) :x{ xx }, y{ yy }{};

  inline void set(INT32 xx, INT32 yy) {
    x = xx; y = yy;
  }
  inline void set(const CGamePoint& pos) {
    x = pos.x; y = pos.y;
  }

  void operator=(const CGamePoint& v) {
    x = v.x;
    y = v.y;
  }

};


class CGameSize {
public:
  INT32 width;
  INT32 height;

public:
  CGameSize() :width{ 0 }, height{ 0 } {};
  CGameSize(INT32 w, INT32 h) :width{ w }, height{ h }{}

  inline void set(INT32 w, INT32 h) {
    width = w; height = h;
  }
  inline void set(const CGameSize& s) {
    width = s.width; height = s.height;
  }

  INT32 getWidth() {
    return width;
  }

  INT32 getHeight() {
    return height;
  }

  void setWidth(INT32 v) {
    width = v;
  }

  void setHeight(INT32 v) {
    height = v;
  }

  void operator=(const CGameSize& v) {
    width = v.width;
    height = v.height;
  }
};

class CGameRect {
public:
  INT32 x, y, width, height, left, top, right, bottom;
  CGamePoint topLeft, bottomRight;

  CGameRect() :x{ 0 }, y{ 0 }, width{ 0 }, height{ 0 }, left{ 0 }, top{ 0 }, right{ 0 }, bottom{ 0 } {
    topLeft.set(0, 0);
    bottomRight.set(0, 0);

  };

  CGameRect(INT32 xx, INT32 yy, INT32 ww, INT32 hh) :x{ xx }, y{yy }, width{ ww }, height{ hh }, left{ xx }, top{ yy }, right{ xx + ww }, bottom{ yy + hh }{
    topLeft.set(left, top);
    bottomRight.set(bottom, right);
  }

  CGameRect(const CGamePoint &pos, const CGameSize &s) :x{ pos.x }, y{ pos.y }, width{ s.width }, height{ s.height }, left{ pos.x }, top{ pos.y }, right{ pos.x + s.width }, bottom{ pos.y + s.height }{
    topLeft.set(left, top);
    bottomRight.set(bottom, right);
  }

  BOOL contains(const CGamePoint &p) {
    if (p.x >= this->left && p.x <= this->right && p.y >= this->top && p.y <= this->bottom)
      return TRUE;

    return FALSE;
  }
};

#endif
